<?php echo $header;echo $sidebar ?>				
<link rel="stylesheet" href="<?php echo base_url() ?>assets/admin/css/jquery-ui.css">
<link rel="stylesheet" href="<?php echo base_url() ?>assets/admin/css/jquery-ui-timepicker-addon.css">
<script type="text/javascript" src="<?php echo base_url() ?>assets/admin/js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="<?php echo base_url() ?>assets/admin/js/jquery-ui.js"></script>
<script type="text/javascript" src="<?php echo base_url() ?>assets/admin/js/jquery-ui-timepicker-addon.js"></script>
		<script>
		  $(function() {
		  
			$("#sdate").datetimepicker( {
				dateFormat:"yy-mm-dd"
			});
			 $("#edate").datetimepicker({
				dateFormat:"yy-mm-dd"
			});
		  });
		</script>
<div class="span10 content">			
    <?php echo $hugemenu ?>			
    <!--h1><?php echo $title;?></h1>			
        <div class="btn-toolbar">                
            <a class="btn" href="<?php echo site_url();?>timesheets/add">
                <i class="icon-plus"></i> <?php echo lang('hrm_sidemenu_timesheet_new')?>
            </a>            
        </div-->
     <h1><?php echo lang('hrm_gride_timesheet_all_title');?>
         <a class="btn btn-success btn-mini" href="<?php echo site_url();?>timesheets/add" style="border-radius: 4px !important;">
    	<i class="icon-plus"></i> <?php echo lang('hrm_sidemenu_new')?>
    </a>
    <?php echo form_open_multipart('timesheets/all/0', array('class' => 'form-horizontal navbar-search pull-right','method'=>'get')); ?>
	    	<div class="input-append">
    		<?php echo form_input(array('name' => 'search-all', 'id' => 'search_all','placeholder'=>'Search', 'class' => 'span2 search_input', 'value' => $search_terms)); ?>
			<?php 
				    $data = array(
				        'name' => 'search',
				        'id' => 'search',
				        'value' => 'true',
				        'type' => 'submit',
				        'content' => '<i class="icon-search"></i>',
				        'class'  => 'btn btn-success search_submit',
				    );
				
				    echo form_button($data);
			?>
			<a class="btn btn-primary search_more" id="more" ><i class="icon-caret-down"></i> More</a>
			</div>    	
		<?php echo form_close(); ?>
	</h1>	
	<div class="filter-box" style="display: none;padding-bottom: 25px;">
		<?php echo form_open_multipart('timesheets/all/0', array('class' => 'form-inline','method'=>'get')); ?>
		<fieldset>
			<legend>Filters</legend>
				<label class="control-label" style="margin: 0px 2px 0px 2px"><?php echo lang('hrm_sidemenu_timesheet_add_form_field_note'); ?></label>
				<?php 
                                
                                $txtsdate = array(
                                           'name'        => 'note',
                                           'id'          => 'note',
                                           'value'       => '',
                                           'maxlength'   => '15',
                                           'size'        => '15',
                                           'class'       => 'span2 date_time',
				 	   'placeholder'=>'Name',
				 	);
                                echo form_input($txtsdate); ?>
				<label class="control-label" style="margin: 0px 2px 0px 2px"><?php echo lang('hrm_employee_name'); ?></label>
				<?php
					$options = array();
					foreach ($this->data['userlist'] as $user):
						$options[$user->id] = $user->username;
					endforeach;	
					$value = ($fill_data->id? $fill_data->user_id : set_value('user_id'));
	
					echo form_dropdown('user_id', $options, $value, 'class="span2"');
				?>
				<label class="control-label" style="margin: 0px 2px 0px 2px"><?php echo lang('hrm_sidemenu_timesheet_add_form_field_status'); ?></label>
				<?php
					$status_options = array();
					foreach ($this->data['statuslist'] as $status):
						$status_options[$status->id] = $status->name;
					endforeach;
					$value = ($fill_data->id? $fill_data->approval_status_id : set_value('approval_status_id'));
	
					echo form_dropdown('approval_status_id', $status_options, $value, 'class="span2" empty="Select Status"');
				?>
				<label class="control-label" style="margin: 0px 2px 0px 2px"><?php echo lang('hrm_sidemenu_timesheet_filters_field_begintime'); ?></label>
				<?php
				 	$txtsdate = array(
                       'name'        => 'sdate',
                       'id'          => 'sdate',
                       'value'       => ($fill_data->id? $fill_data->start_time : set_value('sdate')),
                       'maxlength'   => '20',
                       'size'        => '20',
                       'class'       => 'span2 date_time',
				 	   'placeholder'=>'Begin',
				 	);
				 	echo form_input($txtsdate);
			    ?> 
				<label class="control-label" style="margin: 0px 2px 0px 0px"><?php echo lang('hrm_sidemenu_timesheet_filters_field_stoptime'); ?></label>
				<?php
				 	$txtedate = array(
                       'name'        => 'edate',
                       'id'          => 'edate',
                       'value'       => ($fill_data->id? $fill_data->end_time : set_value('edate')),
                       'maxlength'   => '20',
                       'size'        => '20',
                       'class'       => 'span2 date_time',
				 	   'placeholder'=>'Stop',
				 );
				 	echo form_input($txtedate); 
				?>
				<?php echo form_submit(array('style'=>'margin-top:10px','class'=>'btn btn-info pull-right', 'value' => 'Filter','name'=> 'filter')); ?>
		</fieldset>
		<?php echo form_close(); ?>
    </div>
    
    <?php if($this->session->flashdata('message')) {?>			
        <div class="alert alert-success">				
            <?php echo $this->session->flashdata('message') ?>			
        </div>			
    <?php  }?>			
<div>				

    <table class="table table-striped table-bordered table-hover table-primary">					
    <thead>
        <tr>
            <th><?php echo lang('hrm_gride_timesheet_all_user');?></th>
            <th><?php echo lang('hrm_gride_timesheet_all_job');?></th>
            <th><?php echo lang('hrm_gride_timesheet_all_date');?></th>
            <th><?php echo lang('hrm_gride_timesheet_all_hours');?></th>
            <th><?php echo lang('hrm_gride_timesheet_all_expense');?></th>
            <th><?php echo lang('hrm_gride_timesheet_all_note');?></th>
            <th><?php echo lang('hrm_gride_timesheet_all_status');?></th>
            <th ></th>
        </tr>
    </thead>
    <tbody>
        <?php if (count($timesheet)):?>
        <?php foreach ($timesheet as $timesheet_data):?>
        
        <tr>
            <td><?php echo $timesheet_data->first_name.' '.$timesheet_data->last_name;?></td>
            <td><?php echo $timesheet_data->job_name;?></td>
            <td><?php echo date('d F Y',  strtotime($timesheet_data->start_time));?> - <?php echo date('d F Y',  strtotime($timesheet_data->end_time));?></td>
            <td><?php 
                    $start_date = strtotime($timesheet_data->start_time);
                    $end_date = strtotime($timesheet_data->end_time);
                    $datediff = $end_date - $start_date;
                    echo gmdate("H:i", $datediff);
                    //echo intval(floor($datediff / 3600));
            ?></td>
            <td><?php   $hourly_salary = $timesheet_data->hourly_salary;
                        $salary = round(( $datediff * $hourly_salary / 3600 ),2);
                        echo ($salary ? '$'.$salary : '$0.00' );
              ?></td>
            <td><?php echo $timesheet_data->note;?></td>
            <td class="status-cell">
			<?php if ($timesheet_data->approval_status_id == 1){ ?>
                        <div class="status-labels cell-36">
							<span class="label label-warning">Submitted</span>			
                        </div>
                        <?php } else if ($timesheet_data->approval_status_id == 2) {?>
                        <div class="status-labels cell-36">
                            <span class="label label-success">Approved</span>			
                        </div>
                        <?php } else if ($timesheet_data->approval_status_id == 3) {?>
                        <div class="status-labels cell-35">
							<span class="label label-important">Rejected</span>			
                        </div>    
                        <?php } else if ($timesheet_data->approval_status_id == 4) {?>
                        <div class="status-labels cell-13">
                             <span class="label label-info">Needs revision</span>
                        </div>
                        <?php } ?>
			<div class="status-icons">
				<a href="<?php echo site_url()."timesheets/set_status/1/".$timesheet_data->timesheets_id ?>" class="change-status submitted  row-36  <?php if($timesheet_data->approval_status_id == 1) echo 'status-active';?>" title="Submitted" alt="Submitted" timesheetid="36" statusid="1"><i class="icon-question"></i></a>
				<a href="<?php echo site_url()."timesheets/set_status/2/".$timesheet_data->timesheets_id ?>" class="change-status approved  row-36 <?php if($timesheet_data->approval_status_id == 2) echo 'status-active';?>" title="Approved" alt="Approved" timesheetid="36" statusid="2"><i class="icon-ok"></i></a>
				<a href="<?php echo site_url()."timesheets/set_status/3/".$timesheet_data->timesheets_id ?>" class="change-status rejected  row-36 <?php if($timesheet_data->approval_status_id == 3) echo 'status-active';?>" title="Rejected" alt="Rejected" timesheetid="36" statusid="3"><i class="icon-ban-circle"></i></a>
				<a href="<?php echo site_url()."timesheets/set_status/4/".$timesheet_data->timesheets_id ?>" class="change-status revision  row-36 <?php if($timesheet_data->approval_status_id == 4) echo 'status-active';?>" title="Needs review" alt="Needs review" timesheetid="36" statusid="4"><i class="icon-refresh"></i></a>
				<span class="spinner row-36"></span>
			</div>
            </td>
                                                
            <td width="2px">
                <a class="tooltp" data-toggle="tooltip" title="<?php echo lang('hrm_gride_timesheet_all_edit_tooltip')?>" href="<?php echo site_url()."timesheets/add/".$timesheet_data->timesheets_id ?>"><i class="icon-edit"></i></a>
            </td>
        </tr>
        <?php endforeach;?>
        <?php else: ?>
            <tr><td colspan="9"><center>No record found.</center></p></tr>	
        <?php endif ?>
        
    </tbody>
    </table>
</div>
<?php echo $pagination ?>
</div>

<?php echo $footer ?>